From 0a786a05511e43b81fc69d6749049bf94cb53b0e Mon Sep 17 00:00:00 2001 From: Bastian Germann Date: Sat, 15 Feb 2025 13:12:45 +0000 Subject: [PATCH] Replace _FillValue by NC_FillValue for NetCDF 4.9.3 (Closes: #1095478) --- debian/patches/netcdf-4.9.3.patch | 172 ++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 173 insertions(+) create mode 100644 debian/patches/netcdf-4.9.3.patch diff --git a/debian/patches/netcdf-4.9.3.patch b/debian/patches/netcdf-4.9.3.patch new file mode 100644 index 000000000..57aa25c85 --- /dev/null +++ b/debian/patches/netcdf-4.9.3.patch @@ -0,0 +1,172 @@ +Description: Replace _FillValue by NC_FillValue for NetCDF 4.9.3. +Author: Bas Couwenberg + +--- a/IO/MINC/vtkMINC.h ++++ b/IO/MINC/vtkMINC.h +@@ -178,7 +178,7 @@ use it. + #define MIvalid_range "valid_range" + #define MIvalid_max "valid_max" + #define MIvalid_min "valid_min" +-#define MI_FillValue "_FillValue" ++#define MI_FillValue "NC_FillValue" + #define MItitle "title" + #define MIhistory "history" + +--- a/IO/NetCDF/vtkNetCDFCFWriter.cxx ++++ b/IO/NetCDF/vtkNetCDFCFWriter.cxx +@@ -442,7 +442,7 @@ public: + status = NC_NOERR; + if (std::string(arrayName).rfind("vtk", 0) > 0) + { +- // for an array that starts with vtk we don't specify _FillValue ++ // for an array that starts with vtk we don't specify NC_FillValue + switch (vtkType) + { + case VTK_CHAR: +@@ -451,34 +451,34 @@ public: + if (fillValue != NC_FILL_INT) + { + unsigned char fillByte = fillValue; +- status = nc_put_att(ncid, attributeid, "_FillValue", NC_BYTE, 1, &fillByte); ++ status = nc_put_att(ncid, attributeid, "NC_FillValue", NC_BYTE, 1, &fillByte); + } + break; + case VTK_SHORT: + if (fillValue != NC_FILL_SHORT) + { + short fillShort = fillValue; +- status = nc_put_att_short(ncid, attributeid, "_FillValue", NC_SHORT, 1, &fillShort); ++ status = nc_put_att_short(ncid, attributeid, "NC_FillValue", NC_SHORT, 1, &fillShort); + } + break; + case VTK_INT: + if (fillValue != NC_FILL_INT) + { +- status = nc_put_att_int(ncid, attributeid, "_FillValue", NC_INT, 1, &fillValue); ++ status = nc_put_att_int(ncid, attributeid, "NC_FillValue", NC_INT, 1, &fillValue); + } + break; + case VTK_FLOAT: + if (fillValue != NC_FILL_INT) + { + float fillFloat = fillValue; +- status = nc_put_att_float(ncid, attributeid, "_FillValue", NC_FLOAT, 1, &fillFloat); ++ status = nc_put_att_float(ncid, attributeid, "NC_FillValue", NC_FLOAT, 1, &fillFloat); + } + break; + case VTK_DOUBLE: + if (fillValue != NC_FILL_INT) + { + double fillDouble = fillValue; +- status = nc_put_att_double(ncid, attributeid, "_FillValue", NC_DOUBLE, 1, &fillDouble); ++ status = nc_put_att_double(ncid, attributeid, "NC_FillValue", NC_DOUBLE, 1, &fillDouble); + } + break; + default: +@@ -489,7 +489,7 @@ public: + if (status) + { + std::ostringstream ostr; +- ostr << "Error nc_put_att_xxx " << arrayName << ":_FillValue: " << nc_strerror(status); ++ ostr << "Error nc_put_att_xxx " << arrayName << ":NC_FillValue: " << nc_strerror(status); + throw std::runtime_error(ostr.str()); + } + } +--- a/IO/NetCDF/vtkNetCDFReader.cxx ++++ b/IO/NetCDF/vtkNetCDFReader.cxx +@@ -867,7 +867,7 @@ int vtkNetCDFReader::LoadVariable(int nc + + // Check for a fill value. + size_t attribLength; +- if ((nc_inq_attlen(ncFD, varId, "_FillValue", &attribLength) == NC_NOERR) && (attribLength == 1)) ++ if ((nc_inq_attlen(ncFD, varId, "NC_FillValue", &attribLength) == NC_NOERR) && (attribLength == 1)) + { + if (this->ReplaceFillValueWithNan) + { +@@ -875,7 +875,7 @@ int vtkNetCDFReader::LoadVariable(int nc + if (dataArray->GetDataType() == VTK_FLOAT) + { + float fillValue; +- nc_get_att_float(ncFD, varId, "_FillValue", &fillValue); ++ nc_get_att_float(ncFD, varId, "NC_FillValue", &fillValue); + std::replace(reinterpret_cast(dataArray->GetVoidPointer(0)), + reinterpret_cast(dataArray->GetVoidPointer(dataArray->GetNumberOfTuples())), + fillValue, static_cast(vtkMath::Nan())); +@@ -883,7 +883,7 @@ int vtkNetCDFReader::LoadVariable(int nc + else if (dataArray->GetDataType() == VTK_DOUBLE) + { + double fillValue; +- nc_get_att_double(ncFD, varId, "_FillValue", &fillValue); ++ nc_get_att_double(ncFD, varId, "NC_FillValue", &fillValue); + std::replace(reinterpret_cast(dataArray->GetVoidPointer(0)), + reinterpret_cast(dataArray->GetVoidPointer(dataArray->GetNumberOfTuples())), + fillValue, vtkMath::Nan()); +--- a/IO/NetCDF/vtkNetCDFReader.h ++++ b/IO/NetCDF/vtkNetCDFReader.h +@@ -107,7 +107,7 @@ public: + + ///@{ + /** +- * If on, any float or double variable read that has a _FillValue attribute ++ * If on, any float or double variable read that has a NC_FillValue attribute + * will have that fill value replaced with a not-a-number (NaN) value. The + * advantage of setting these to NaN values is that, if implemented properly + * by the system and careful math operations are used, they can implicitly be +--- a/IO/NetCDF/vtkNetCDFUGRIDReader.cxx ++++ b/IO/NetCDF/vtkNetCDFUGRIDReader.cxx +@@ -508,10 +508,10 @@ bool vtkNetCDFUGRIDReader::ParseHeader() + if (this->NodesPerFace > 3) // may be mixed mesh + { + if (!this->CheckError( +- nc_get_att(this->NcId, this->FaceVarId, "_FillValue", &this->FaceFillValue))) ++ nc_get_att(this->NcId, this->FaceVarId, "NC_FillValue", &this->FaceFillValue))) + { +- vtkErrorMacro("_FillValue attribute missing - The connectivity variable has to specify a " +- "_FillValue attribute because it has more than 3 nodes per face"); ++ vtkErrorMacro("NC_FillValue attribute missing - The connectivity variable has to specify a " ++ "NC_FillValue attribute because it has more than 3 nodes per face"); + return false; + } + } +@@ -859,7 +859,7 @@ struct DataArrayExtractor + if (replaceFill && (std::is_same::value || std::is_same::value)) + { + T fillValue{}; +- if (nc_get_att(NcId, var, "_FillValue", &fillValue) != NC_NOERR) ++ if (nc_get_att(NcId, var, "NC_FillValue", &fillValue) != NC_NOERR) + { + vtkDebugWithObjectMacro(output, "No fill value defined"); + return; +--- a/IO/NetCDF/vtkNetCDFUGRIDReader.h ++++ b/IO/NetCDF/vtkNetCDFUGRIDReader.h +@@ -76,7 +76,7 @@ public: + + ///@{ + /** +- * If on, any float or double variable read that has a _FillValue attribute ++ * If on, any float or double variable read that has a NC_FillValue attribute + * will have that fill value replaced with a not-a-number (NaN) value. The + * advantage of setting these to NaN values is that, if implemented properly + * by the system and careful math operations are used, they can implicitly be +--- a/ThirdParty/exodusII/vtkexodusII/src/ex_put_prop.c ++++ b/ThirdParty/exodusII/vtkexodusII/src/ex_put_prop.c +@@ -243,7 +243,7 @@ int ex_put_prop(int exoid, ex_entity_typ + vals[0] = 0; /* fill value */ + /* create attribute to cause variable to fill with zeros per routine spec + */ +- if ((status = nc_put_att_longlong(exoid, propid, _FillValue, int_type, 1, vals)) != NC_NOERR) { ++ if ((status = nc_put_att_longlong(exoid, propid, NC_FillValue, int_type, 1, vals)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to create property name fill attribute in file id %d", exoid); + ex_err_fn(exoid, __func__, errmsg, status); +--- a/ThirdParty/exodusII/vtkexodusII/src/ex_put_prop_names.c ++++ b/ThirdParty/exodusII/vtkexodusII/src/ex_put_prop_names.c +@@ -172,7 +172,7 @@ int ex_put_prop_names(int exoid, ex_enti + + /* create attribute to cause variable to fill with zeros per routine spec + */ +- if ((status = nc_put_att_longlong(exoid, propid, _FillValue, int_type, 1, vals)) != NC_NOERR) { ++ if ((status = nc_put_att_longlong(exoid, propid, NC_FillValue, int_type, 1, vals)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to create property name fill attribute in file id %d", exoid); + ex_err_fn(exoid, __func__, errmsg, status); diff --git a/debian/patches/series b/debian/patches/series index 5e65f978d..5368f429f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -13,3 +13,4 @@ 100_add_missing_gl_header.patch 121_add_support_for_loong64.patch 130_fix_python_3.13.patch +netcdf-4.9.3.patch -- 2.30.2